package com.meida.student.app.init;

import com.meida.common.base.entity.EntityMap;
import com.meida.module.bus.provider.service.BusOrderAnswerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Slf4j
@Component
public class InitBusOrderAnswer implements InitializingBean {
    @Autowired
    private BusOrderAnswerService busOrderAnswerService;

    @Override
    public void afterPropertiesSet() throws Exception {
        //处理订单答案
        log.info("InitBusOrderAnswer:-------------处理订单答案佣金结算");
        List<EntityMap> entityMapList = busOrderAnswerService.querySettleExpireOrderAnswer();
        entityMapList.forEach(entityMap -> {
            Long answerId = entityMap.getLong("answerId");
            busOrderAnswerService.orderAnswerSettleCommission(answerId);
        });
    }
}
